package com.whosly.foundationdb.study.controller.handler;

import com.whosly.foundationdb.study.controller.IController;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import java.text.SimpleDateFormat;
import java.util.Date;

import static org.springframework.web.reactive.function.server.ServerResponse.ok;

@Component
public class FDBHandler implements IController  {

    /**
     *
     */
    public Mono<ServerResponse> query(ServerRequest request) {
        return ok().contentType(MediaType.APPLICATION_JSON)
//                .body(BodyInserters.fromObject("Hi , this is SpringWebFlux~~~"));
                .body(
                        Mono.just("Now is " + new SimpleDateFormat("HH:mm:ss").format(new Date())), String.class
                );
    }

}
